package br.gendi.rcp.test;
import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

import br.gendi.beans.Product;

import au.id.jericho.lib.html.FormField;
import au.id.jericho.lib.html.FormFields;
import au.id.jericho.lib.html.Source;

public class FormFieldList {
	public static void main(String[] args) throws Exception {

		String sourceUrlString = "http://www.google.com";

		if (sourceUrlString.indexOf(':') == -1)
			sourceUrlString = "file:" + sourceUrlString;

		Product p = new Product();
		
		Source source = new Source(new URL(sourceUrlString));
		FormFields formFields = source.findFormFields();

		HashMap hm = new HashMap();
		for (Iterator i = formFields.iterator(); i.hasNext();) {
			FormField formField = (FormField) i.next();
			System.out.println(formField.getFormControl());
			System.out.println(formField.getFormControl().getSource().toString().indexOf("action"));
			
			/*
			p.setUrl(sourceUrlString);
			p.setMethod("GET");
			
			System.out.println(formField.getName());
			System.out.println(formField.getPredefinedValues());
			
			p.setParamethers(formField.getName(),formField.getPredefinedValues());
			*/
			
		}
		//System.out.println(p.getMethod());
		//System.out.println(p.getParamethers("ie"));
	}
}
